﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using Microsoft.Surface;
using Microsoft.Surface.Presentation;
using Microsoft.Surface.Presentation.Controls;

namespace BaseAttack
{
    public class Target
    {
        private Canvas UI;
        private Rectangle TargetBody;
        private Point Position;
        private double Health = 100;
        private Boolean Destroyed = false;

        public Target(Canvas UI, Point Position)
        {
            this.Position = Position;
            this.UI = UI;

            // Set up the drawable
            TargetBody = new Rectangle();
            TargetBody.Height = 40;
            TargetBody.Width = 40;
            TargetBody.Fill = Brushes.Red;
            TargetBody.HorizontalAlignment = HorizontalAlignment.Left;
            TargetBody.VerticalAlignment = VerticalAlignment.Top;
            UI.Children.Add(TargetBody);

            Canvas.SetTop(TargetBody, Position.Y - (TargetBody.Height / 2));
            Canvas.SetLeft(TargetBody, Position.X - (TargetBody.Width / 2));
        }

        public void DecreaseHealth(double ByAmount) {
            Health -= ByAmount;
            if (Health < 0) 
            {
                Health = 0;
                Destroyed = true;
            }
            TargetBody.Fill = new SolidColorBrush(Color.FromRgb((byte)(255 * (Health / 100)), 0, 0));
        }

        public Point Center {
            get { return this.Position; }
        }
        public Boolean Alive
        {
            get { return !Destroyed; }
        }

        public double getHealth()
        {
            return this.Health;
        }
        public void setDestroyed(bool d)
        {
            this.Destroyed = d;
        }
    }
}
